import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

browser = webdriver.Chrome(service=Service("E:\\chrome\\chromedriver.exe"))
browser.maximize_window()
browser.get("http://sce1.sce.ncu.edu.cn/")
time.sleep(3)
browser.find_element(By.ID,"phoneName").send_keys("18379432324")
browser.find_element(By.ID,"phonepassword").send_keys("Djc1234@")
time.sleep(1)
browser.find_element(By.XPATH,'//*[@id="phoneloginForm"]/div[3]/button').click()
time.sleep(5)
js = 'window.open("http://mooc1.sce.ncu.edu.cn/mycourse/studentstudy?chapterId=498297126&courseId=221712838&clazzid=53094311&enc=9db25c8da65eb48aab521e272fa9cb39");'
browser.execute_script(js)
# select="document.querySelector('right ui-widget-content').scrollTo(0,500)"
# browser.execute_script(select)
time.sleep(2)
# browser.find_element(By.XPATH,'//*[@id="xqkcdiv_45881"]/div[7]/div/h3/a/text()')
handler=browser.window_handles
time.sleep(3)
browser.switch_to.window(handler[-1])
i =22231
# for i in range(50):
browser.find_element(By.ID,'cur4983'+str(i)).click()
time.sleep(2)
iframe = browser.find_elements(By.TAG_NAME,"iframe")[0]
browser.switch_to.frame(iframe)
time.sleep(1)
iframe = browser.find_elements(By.TAG_NAME,"iframe")[0]
browser.switch_to.frame(iframe)
time.sleep(2)
browser.find_element(By.CLASS_NAME,'vjs-big-play-button').click()



# list=browser.find_elements(By.CLASS_NAME,"articlename")
# for i in range(len(list)):
#     browser.find_elements(By.CLASS_NAME,"articlename")[i].click()
#     if

# for i in range(50):
#     browser.find_element(By.ID,"cur498336689").click()
#     time.sleep(2)
#     browser.find_element(By.CLASS_NAME,"vjs-big-play-button")
